package com.star.example.consumer;

/**
 * packageName com.star.example.consumer
 *
 * @author zerostart
 * @className EasyConsumerExample
 * @date 2024/11/17
 * @description
 */

import com.star.example.common.model.User;
import com.star.example.common.service.UserService;
import com.star.rpc.RpcApplication;
import com.star.rpc.config.RpcConfig;
import com.star.rpc.proxy.ClassProxyFactory;
import com.star.rpc.utils.ConfigUtils;


/**
 * 简单消费者示例
 */
public class EasyConsumerExample {

    public static void main(String[] args) {
//        proxy();
//        RpcConfig rpc = ConfigUtils.loadConfig(RpcConfig.class, "rpc");
//        System.out.println(rpc);

        UserService userService = ClassProxyFactory.getProxy(UserService.class);
        if (userService == null) {
            System.out.println("userService==null");
        }
        User user = new User();

        user.setName("star");
        System.out.println("远程调用开始");
        User newUser = userService.getUser(user);

        if (newUser != null) {
            System.out.println("11111111111111111111111111111111111111111111111111");
            System.out.println(user.getName());
        } else {
            System.out.println("user==null");
        }

    }


    public static void proxy() {
        UserService userService = ClassProxyFactory.getProxy(UserService.class);
        User user = new User();

        user.setName("star");
        User newUser = userService.getUser(user);

        if (newUser != null) {
            System.out.println(user.getName());
        } else {
            System.out.println("user==null");
        }
    }

}
